const state = {
//   nodeInfo: JSON.parse(sessionStorage.getItem('nodeInfo')) || {},
//   condition: JSON.parse(sessionStorage.getItem('condition')) || {}
  nodeInfo: {},
  condition: {}
}
const mutations = {
// 开局获取所有节点信息
  getNodeInfo(state, data) {
    state.nodeInfo = data
    // var e = JSON.stringify(data)
    // sessionStorage.setItem('nodeInfo', e)
  },
  // 开局获取所有连线信息
  getCondition(state, data) {
    state.condition = data
    // var e = JSON.stringify(data)
    // sessionStorage.setItem('condition', e)
  },
  // 更改单个节点信息
  changeNodeInfo(state, data) {
    for (const key in data) {
      state.nodeInfo[key] = data[key]
    }
    // var e = JSON.stringify(state.nodeInfo)
    // sessionStorage.setItem('nodeInfo', e)
  },
  //   更改连线信息
  changeCondition(state, data) {
    for (const key in data) {
      state.condition[key] = data[key]
    }

    // var e = JSON.stringify(state.condition)
    // sessionStorage.setItem('condition', e)
  },
  //  删除节点
  deleteNodeInfo(state, data) {
    setTimeout(() => {
      if (!Object.keys(state.nodeInfo).length) return
      for (const key in state.nodeInfo) {
        if (key === data) delete state.nodeInfo[key]
      }
    }, 100)
  }
}
export default {
  namespaced: true,
  state,
  mutations
}

